import { _decorator, director, EventTarget } from 'cc';
// import S2048_GameManager from "../../SubGame/2048/Script/S2048_GameManager";
// import DragTetris_GameManager from "../../SubGame/DragTetris/Script/Manager/DragTetris_GameManager";
// import TurkishTetris_GameManager from "../../SubGame/TurkishTetris/game/Script/XXL/Manager/TurkishTetris_GameManager";
// import { SSS_Consts } from "../Data/SSS_Consts";
// import YangLeGeYang_GameManager from "../../SubGame/YangLeGeYang/Script/Manager/YangLeGeYang_GameManager";
// import { ShuZiHuaRongDao_GameManager } from "../../SubGame/ShuZiHuaRongDao/Script/ShuZiHuaRongDao_GameManager";
// import HeChengDaXiGua_GameManager from "../../SubGame/HeChengDaXiGua/Script/HeChengDaXiGua_GameManager";
// import Minesweeper_GameManager from "../../SubGame/Minesweeper/Script/Manager/Minesweeper_GameManager";
// import CircleTheCat_GameManager from "../../SubGame/CircleTheCat/CircleTheCat_GameManager";
// import Gomoku_GameManager from "../../SubGame/Gomoku/Script/Gomoku_GameManager";
// import { LianLianKan } from '../../SubGame/LianLianKan/script/LianLianKan';
// import DaoShuiPaiXu_GameManager from '../../SubGame/DaoShuiPaiXu/Script/DaoShuiPaiXu_GameManager';

const { ccclass, property } = _decorator;

// /** 事件 */
export const SS_GameEventData = {
    Change_Scene: "Change_Scene",
    Home: "Home",
    Menu: "Menu",
    Replay: "Replay",
    Next_Level: "Next_Level",
    Revive: "Revive",
    广告结束: "广告结束",
};

// export const eventTarget = new EventTarget();

@ccclass('SSS_GameEventManager')
export default class SSS_GameEventManager {
    static eventTarget = null;

    static Init() {
        SSS_GameEventManager.eventTarget = new EventTarget();

        SSS_GameEventManager.AddListener();
    }

    static AddListener() {
        SSS_GameEventManager.eventTarget.on(SS_GameEventData.Home, this.On_Home, this);
        SSS_GameEventManager.eventTarget.on(SS_GameEventData.Menu, this.On_Menu, this);
        SSS_GameEventManager.eventTarget.on(SS_GameEventData.Next_Level, this.On_Next_Level, this);
        SSS_GameEventManager.eventTarget.on(SS_GameEventData.Replay, this.On_Replay, this);
        SSS_GameEventManager.eventTarget.on(SS_GameEventData.Revive, this.On_Revive, this);
        // systemEvent.on(SS_GameEventData.Change_Scene, this.On_Change_Scene, this);
    }

    static async On_Home(msg) {
        // director.loadScene(SSS_Consts.SceneName.MainScene);
    }
    static async On_Menu(msg) {
        const currentScene = director.getScene();
        const name = currentScene.name;
        console.log('当前场景:', name);

        // if (name === SSS_Consts.SceneName.DanCiPeiDui_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.DanCiPeiDui_Level_Scene);
        // }
        // else if (name === SSS_Consts.SceneName.YangLeGeYang_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.DanCiFanFanLe_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.DanCiFanFanLe_Level_Scene);
        // }
        // else if (name === SSS_Consts.SceneName.土耳其方块_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.俄罗斯拖方块_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.飞翔小鸟) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.S2048_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.ShuZiHuaRongDao_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.HeChengDaXiGua_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.Minesweeper_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.CircleTheCat_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.Gomoku_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.JiuJiuXiaoDongWu_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.MainScene);
        // }
        // else if (name === SSS_Consts.SceneName.DaoShuiPaiXu_Game_Scene) {
        //     director.loadScene(SSS_Consts.SceneName.DaoShuiPaiXu_Main_Scene);
        // }
    }
    static async On_Next_Level(msg) {
        const currentScene = director.getScene();
        const name = currentScene.name;
        console.log('当前场景:', name);

        // if (name === SSS_Consts.SceneName.YangLeGeYang_Game_Scene) {
        //     YangLeGeYang_GameManager.Instance.下一关();
        // }
        // else if (name === SSS_Consts.SceneName.LianLianKan_Game_Scene) {
        //     LianLianKan.Instance.下一关();
        // }
    }

    static async On_Replay(msg) {
        const currentScene = director.getScene();
        const name = currentScene.name;
        console.log('当前场景:', name);

        // if (name === SSS_Consts.SceneName.DanCiPeiDui_Game_Scene) {
        //     // DanCiPeiDui.Instance.Replay();
        // }
        // else if (name === SSS_Consts.SceneName.YangLeGeYang_Game_Scene) {
        //     YangLeGeYang_GameManager.Instance.Replay();
        // }
        // else if (name === SSS_Consts.SceneName.土耳其方块_Game_Scene) {
        //     TurkishTetris_GameManager.Instance.ReStart();
        //     // director.loadScene(director.getScene().name);
        // }
        // else if (name === SSS_Consts.SceneName.俄罗斯拖方块_Game_Scene) {
        //     director.loadScene(director.getScene().name);
        // }
        // else if (name === SSS_Consts.SceneName.S2048_Game_Scene) {
        //     S2048_GameManager.Instance.Replay();
        //     // director.loadScene(director.getScene().name);
        // }
        // else if (name === SSS_Consts.SceneName.ShuZiHuaRongDao_Game_Scene) {
        //     ShuZiHuaRongDao_GameManager.Instance.Replay();
        // }
        // else if (name === SSS_Consts.SceneName.HeChengDaXiGua_Game_Scene) {
        //     HeChengDaXiGua_GameManager.Instance.Replay();
        // }
        // else if (name === SSS_Consts.SceneName.Minesweeper_Game_Scene) {
        //     Minesweeper_GameManager.Instance.Replay();
        // }
        // else if (name === SSS_Consts.SceneName.CircleTheCat_Game_Scene) {
        //     CircleTheCat_GameManager.Instance.Replay();
        // }
        // else if (name === SSS_Consts.SceneName.Gomoku_Game_Scene) {
        //     Gomoku_GameManager.Instance.Replay();
        // }
        // else if (name === SSS_Consts.SceneName.DaoShuiPaiXu_Game_Scene) {
        //     DaoShuiPaiXu_GameManager.Instance.Replay();
        // }
    }
    static async On_Revive(msg) {
        const currentScene = director.getScene();
        const name = currentScene.name;
        console.log('当前场景:', name);

        // if (name === SSS_Consts.SceneName.DanCiPeiDui_Game_Scene) {

        // }
        // else if (name === SSS_Consts.SceneName.YangLeGeYang_Game_Scene) {
        //     YangLeGeYang_GameManager.Instance.Reborn();
        // }
        // else if (name === SSS_Consts.SceneName.土耳其方块_Game_Scene) {
        //     TurkishTetris_GameManager.Reborn();
        //     // TurkishTetris_GameManager.Instance.Reborn()
        // }
        // else if (name === SSS_Consts.SceneName.俄罗斯拖方块_Game_Scene) {
        //     DragTetris_GameManager.Instance.Reborn();
        // }
        // else if (name === SSS_Consts.SceneName.S2048_Game_Scene) {

        // }
        // else if (name === SSS_Consts.SceneName.DaoShuiPaiXu_Game_Scene) {
        //     DaoShuiPaiXu_GameManager.Instance.Reborn();
        // }
    }
    //    // static async On_Change_Scene(msg) {
    //    // }
}

// /** 调试 */
window["SS_GameEventManager"] = SSS_GameEventManager;